﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security;

public delegate void OutputCallback(string text, bool newline= true);

namespace PasswordManagerTest
{
    public class TestSetup
    {
        private string UserDocDir;
        public string UserTestDir { get; private set; }
        private bool sgx;
        OutputCallback output;

        public TestSetup()
        {
            UserDocDir = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            UserTestDir = UserDocDir;
            Console.OutputEncoding = System.Text.Encoding.Unicode;
            sgx = false;
            output = this.OutputConsole;
            // Or change it to somewhere else if you prefer
            //UserTestDir = String.Format("{0}\\CLI PW Testing", UserDocDir);
        }

        public void setOutputCallback(OutputCallback callback)
        {
            output = callback;
        }

        public void setTestFolder(string path)
        {
            UserTestDir = path;
        }

        public void setSGXSupport (bool state)
        {
            sgx = state;
        }

        public bool getSGXSupport ()
        {
            return sgx;
        }

        public string getTestFolder ()
        {
            return UserTestDir;
        }

        public OutputCallback getOutputCallback()
        {
            return output;
        }

        public string VaultPath(string filename)
        {
            return string.Format("{0}\\{1}.vlt", UserTestDir, filename);
        }

        public void OutputConsole(string text, bool newline= true)
        {
            if (newline) { Console.WriteLine(text); }
            else { Console.Write(text); }
        }
    }
}
